package edu.pw.treegrid.client.report.view;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;

import edu.pw.treegrid.client.report.controller.ReportController;

public class ReportToolbar extends ToolStrip {
	
	private ReportController controller;
	
	public ReportToolbar(ReportController controller, String reportId) {
		this.controller = controller;
		this.setWidth100();
        ToolStripButton printButton = new ToolStripButton();
        printButton.setIcon("silk/printer.png");
        printButton.setTitle("Print");
        this.addButton(printButton);
        
        printButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ReportToolbar.this.controller.onPrintPreview();
			}
		});
        
        ToolStripButton settingsButton = new ToolStripButton();
        settingsButton.setIcon("pieces/24/cube_frame.png");
        settingsButton.setTitle("Ustawienia");
        this.addButton(settingsButton);
        settingsButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ReportToolbar.this.controller.onShowSettings();
			}
		});
        
        Canvas canvas = new Canvas();
        canvas.setHeight(16);
        canvas.setWidth(16);
        String href = "app/excelExport.xls?reportId=" + reportId;
        canvas.setContents("<a href='" + href + "'><img src='images/icon_export_xls.gif' border='0'></a>");
        this.addMember(canvas);
        
        ToolStripButton helpButton = new ToolStripButton();
        helpButton.setIcon("info.png");
        helpButton.setTitle("Informacja");
        this.addButton(helpButton);
        helpButton.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				ReportToolbar.this.controller.onHelp();
			}
		});
        
	}
}
